package org.jash.shop2202.entity

import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import org.jash.shop2202.BR
import org.jash.shop2202.utils.bus
import org.jash.shop2202.utils.logging

data class CartItem(
    val goods_default_icon: String,
    val goods_default_price: Float,
    val goods_desc: String,
    val goods_id: Int,
    val id: Int,
    val order_id: Int,
    val user_id: Int
):BaseObservable() {
    @Bindable
    var checked:Boolean = false
        set(value) {
            field = value
            notifyPropertyChanged(BR.checked)
            bus.postValue("更新购物车" to "")
        }
    @Bindable
    var count: Int = 0
        set(value) {
            if (value > 0) {
                field = value
                notifyPropertyChanged(BR.count)
                bus.postValue("更新购物车" to "")
            }
        }
    fun countPlus(n:Int) {
        count += n
    }
    fun delete() {
        bus.postValue("删除购物车" to this)
    }
}

